package com.wyh.utils.feemanagementutils;

import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.Random;


@Component
public class CheckCodeUtil {

    private static final String[] ARR = {"0","1","2","3","4","5","6","7","8","9"};
    private static final Random random = new Random();

    /**
     * 生成指定长度的随机验证码
     * @param length 指定验证码长度
     * @return 验证码
     */
    public  String generateCheckCode(int length){
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int index = random.nextInt(ARR.length);
            sb.append(ARR[index]);
        }
        return sb.toString();
    }

}
